-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add advanced code example to documentation #3026
Conversation
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6882249059/npm-package-wrangler-3026 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6882249059/npm-package-wrangler-3026 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6882249059/npm-package-wrangler-3026 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6882249059/npm-package-miniflare-3026 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6882249059/npm-package-cloudflare-pages-shared-3026 Note that these links will no longer work once the GitHub Actions artifact expires.
| Please ensure constraints are pinned, and |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3026 +/- ##
==========================================
+ Coverage 75.46% 75.50% +0.03%
==========================================
Files 225 225
Lines 12478 12478
Branches 3239 3239
==========================================
+ Hits 9417 9421 +4
+ Misses 3061 3057 -4 |
Please run Prettier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The messaging needs some rewording and the formatter needs to be ran on the file. If the formatter makes the snippet look off we can add that to the prettier/linter ignore
Co-authored-by: Jacob M-G Evans <27247160+JacobMGEvans@users.noreply.github.com>
Checks are failing because a test timed out: |
I suggest we use example from the workers-rs repo, it's compact and does the job. use worker::*;
#[event(fetch)]
pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
console_log!(
"{} {}, located at: {:?}, within: {}",
req.method().to_string(),
req.path(),
req.cf().coordinates().unwrap_or_default(),
req.cf().region().unwrap_or("unknown region".into())
);
if !matches!(req.method(), Method::Post) {
return Response::error("Method Not Allowed", 405);
}
if let Some(file) = req.form_data().await?.get("file") {
return match file {
FormEntry::File(buf) => {
Response::ok(&format!("size = {}", buf.bytes().await?.len()))
}
_ => Response::error("`file` part of POST form must be a file", 400),
};
}
Response::error("Bad Request", 400)
} |
@JacobMGEvans are you happy with these changes? If so, would you be able to approve and merge? |
@Alex1607 Could this link to |
hi @Alex1607 :) could you please note that the snippet comes from |
Add link to workers-rs
@jspspike @lrapoport-cf sorry for the delay, I just adjusted the readme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
How is the merging done? Do I still have to do something, or will someone take over from now? |
thanks @Alex1607 , we've merged the change 👍 |
What this PR solves / how to test:
In my opinion, removing the code example and just using a bare-bones file leaves a lot of new starters in the dark. Therefore, I added the old code as an advanced example to the documentation.
Associated docs issue(s)/PR(s):
Author has included the following, where applicable:
Reviewer has performed the following, where applicable: